package com.chengliang.zuoye.service.impl;

import com.chengliang.zuoye.bean.Role;
import com.chengliang.zuoye.mapper.RoleMapper;
import com.chengliang.zuoye.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author jerry
 */
@Service
public class RoleServiceImpl implements RoleService {

    private final RoleMapper roleMapper;

    @Autowired
    public RoleServiceImpl(RoleMapper roleMapper) {
        this.roleMapper = roleMapper;
    }

    /**
     * 添加角色
     *
     * @param role    角色信息
     * @param menuIds 角色对应菜单ID
     * @return
     */
    @Override
    public boolean saveRole(Role role, List<Integer> menuIds) {
        //添加角色信息
        return roleMapper.insert(role)!=0;
    }

    @Override
    public List<Role> roleList() {
        return roleMapper.selectAll();
    }

    @Override
    public boolean deleteRoleById(Integer id) {
        return roleMapper.deleteByPrimaryKey(id)!=0;
    }

    @Override
    public boolean deleteRoleByIds(List<Integer> ids) {
        return roleMapper.deleteRoleByIds(ids);
    }


}
